var polygonSearch = {
	map: null,
	resultArr: null,
	container: null,
	pagination: null,
	searchRes_firstPage: null,
	measuregeometry: null,
	searchhandler: null,

	init: function() {
		this.resultArr = new Array();
		this.map = MapObj.getMap();

		//监听点击事件：区域查询
		var btn_block = document.getElementById("search_block");
		btn_block.addEventListener("tap", function() {
			resultDisplay = 0;
			$('#cehua').css('display', 'block');
			MapObj.mapClear();
			AllWindowClose();
			mui.toast('点击屏幕开始勾画多边形');
			toolbartag = 'PolygonSearch';
			DrawTool.init(MapObj.getMap());
			DrawTool.activate("polygon", toolbartag);

		});
		//添加raw-end自定义事件监听(绘画完)
		window.addEventListener('draw-end', function() {
			//获得事件参数
			//         var geometry = event.detail.geometry;
			var geometry = DrawTool.lastgeomtry;
			var symbol;
			switch(geometry.type) {
				case "polyline":
					symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2);
					break;
				case "polygon":
					symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID,
						new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2),
						new dojo.Color([255, 255, 0, 0.25]));
					break;
			}

			this.map.showZoomSlider(); //在地图上显示的缩放滑块
			// 判断几何图形的类型
			var graphic = new esri.Graphic(geometry, symbol);
			MapObj.drawgraphicLayer.add(graphic); // 将绘图加入到图层中  

			polygonSearch.beginSearch(graphic);

		});
	},

	clear: function() {
		//MapObj.drawgraphicLayer.clear();
		//map.infoWindow.hide();
		//解除事件
		// DrawTool.clear();

	},
	beginSearch: function(gra) {
		var geom = gra.geometry;
		var identifyTask = null;
		var identifyParams = null;

		identifyTask = new esri.tasks.IdentifyTask(parent.deepwellUrl); //查询
		identifyParams = new esri.tasks.IdentifyParameters(); //查询参数
		identifyParams.tolerance = 3; //容差范围
		identifyParams.returnGeometry = true; //是否返回图形
		identifyParams.layerIds = [1]; //查询图层
		identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; //设置查询的图层
		//查询范围
		identifyParams.width = map.width;
		identifyParams.height = map.height;
		identifyParams.geometry = geom;
		identifyParams.mapExtent = map.extent;
		identifyTask.execute(
			identifyParams,
			function(results) {
				if(results.length > 0) {
					resultDisplay = 1;
					$('#cehua').css('display', 'block');
					GMQuery.configFindResultArray(results);
					GMQuery.configResultList(GMQuery.resultArr);
					//chrli 这里要接着查询pdf
					GMQuery.showWin();
					setResultTitle("qy");
					offCanvasWrapperShow();

				} else {
					mui.alert("抱歉，没有搜索到记录", "提示");
					return;
				}
			});

	}

}